package com.ruoyi.thread;

public class ThreadGroupTest {
    public static void main(String[] args) {
        // 创建线程组
        ThreadGroup threadGroup = new ThreadGroup("nezha");

        Thread thread = new Thread(threadGroup,()->{
            // 线程组名称
            String groupName = Thread.currentThread().getThreadGroup().getName();
            // 线程名称
            String threadName = Thread.currentThread().getName();
            System.out.println("groupName -- "+groupName);//groupName -- nezha
            System.out.println("threadName -- "+threadName);//threadName -- thread
        },"thread");

//        thread.start();

        Thread daemonTread = new Thread();

        // 设定 daemonThread 为 守护线程，默认false
        daemonTread.setDaemon(true);

        // 验证当前线程是否为守护线程，返回 true 则为守护线程
        daemonTread.isDaemon();
    }
}
